package com.soft.javase.day14.fileupload;

import java.io.*;
import java.net.Socket;
import java.net.UnknownHostException;

/**
 * @author yzg
 * @desc TODO
 * @date 2025/5/24
 */
public class FileUploadClient {
    public static void main(String[] args) {
        try (
                BufferedInputStream bis = new BufferedInputStream(new FileInputStream("C:\\Users\\33552\\Pictures\\Saved Pictures\\Java.png"));
                Socket socket = new Socket("127.0.0.1", 8888);
                BufferedOutputStream bos = new BufferedOutputStream(socket.getOutputStream())
        ) {
            byte[] b = new byte[8192];
            int len;
            while ((len = bis.read(b)) != -1) {
                bos.write(b, 0, len);
            }
            System.out.println("文件上传结束");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
